﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dept_Dict.aspx.cs" Inherits="KPI_SYSTEM.DictPage.Dept_Dict" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Grid ID="Grid1" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="true" EnableCollapse="false"
            runat="server" DataKeyNames="REC_ID" AllowCellEditing="false" PageSize="15" AllowPaging="true" 
            DataIDField="REC_ID" Title="部门信息维护" OnRowCommand="Grid1_RowCommand" OnPreRowDataBound="Grid1_PreRowDataBound">
            <Toolbars>
                <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                    <Items>
                        <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                            <Listeners>
                                <f:Listener Event="click" Handler="onNewButtonClick" />
                            </Listeners>
                        </f:Button>
                        <f:Button ID="btnSyncDept" Text="同步钉钉" Icon="ArrowDown"  runat="server" OnClick="btnSyncDept_Click">
                        </f:Button>
                    </Items>
                </f:Toolbar>
            </Toolbars>
            <Columns>
                <f:RenderField Width="200px" ColumnID="DEPT_NAME" DataField="DEPT_NAME"
                    HeaderText="部门名称">
                </f:RenderField>
                 <f:RenderField Width="150px" ColumnID="DING_CODE" DataField="DING_CODE"
                    HeaderText="部门编码">
                </f:RenderField>
                <f:RenderField Width="200px" ColumnID="PATENT_NAME" DataField="PATENT_NAME"
                    HeaderText="上级部门">
                </f:RenderField>
<%--                <f:RenderField Width="150px" ColumnID="DING_CODE" DataField="DING_CODE"
                    HeaderText="钉钉编码">
                </f:RenderField>--%>
<%--                 <f:RenderField Width="150px" ColumnID="WARD_CODE" DataField="WARD_CODE"
                    HeaderText="病区编码">
                </f:RenderField>--%>
<%--                <f:RenderField Width="150px" ColumnID="DEPT_TYPE_NAME" DataField="DEPT_TYPE_NAME"
                    HeaderText="部门类别">
                </f:RenderField>--%>
                <f:RenderField Width="150px" ColumnID="DEPT_STATUS_NAME" DataField="DEPT_STATUS_NAME"
                    HeaderText="是否启用">
                </f:RenderField>
                <f:RenderField Width="150px" ColumnID="DEPT_REMARK" DataField="DEPT_REMARK"
                    HeaderText="备注">
                </f:RenderField>
                 <f:RenderField Width="150px" Hidden="true" ColumnID="PARENT_ID" DataField="PARENT_ID"
                    HeaderText="上级部门ID">
                </f:RenderField>
<%--                 <f:RenderField Width="150px" Hidden="true" ColumnID="DEPT_TYPE" DataField="DEPT_TYPE"
                    HeaderText="部门类别ID">
                </f:RenderField>--%>
                <f:RenderField Width="150px" Hidden="true" ColumnID="DEPT_STATUS" DataField="DEPT_STATUS"
                    HeaderText="部门启用状态">
                </f:RenderField>
                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false"
                    Icon="Pencil" />
                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                    CommandName="Delete" Icon="Delete" />
            </Columns>
        </f:Grid>

        <f:Window ID="Window1" Title="编辑部门" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="650px">
            <Items>
                <f:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:Panel ID="Panel1" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:HiddenField ID="hfFormID" runat="server"></f:HiddenField>
                                <f:TextBox ID="tbxFormDEPT_NAME" Width="310px" Label="部门名称" runat="server" Required="true" ShowRedStar="true"></f:TextBox>
                                <f:TextBox ID="tbxFormDING_CODE" Width="310px" MarginLeft="20px"  Label="部门编码" runat="server"></f:TextBox>
                               
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel2" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <%--<f:TextBox ID="tbxFormDEPT_CODE" Width="310px" Label="部门编码" Required="true" ShowRedStar="true" runat="server"></f:TextBox>--%>
                                 <f:DropDownList ID="ddlFormPARENT_ID" Width="310px"  Label="上级部门"  AutoSelectFirstItem="true" runat="server">
                                </f:DropDownList>
                                 <f:DropDownList ID="ddlFormDEPT_STATUS" Width="310px" MarginLeft="20px" Label="是否启用"  AutoSelectFirstItem="true" runat="server">
                                   <f:ListItem Text="是" Value="1" />
                                    <f:ListItem Text="否" Value="0" />
                             </f:DropDownList>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel3" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                               <f:TextBox ID="tbxFormDEPT_REMARK"   Label="备注" runat="server"></f:TextBox>
                             <%-- <f:TextBox ID="tbxFormWARD_CODE" Width="310px" Label="病区编码" runat="server"></f:TextBox>--%>
                             <%-- <f:DropDownList ID="ddlFormDEPT_TYPE" Width="310px" MarginLeft="20px" Label="部门类别" AutoSelectFirstItem="true" runat="server">
                             </f:DropDownList>--%>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel4" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                             
                               
                            </Items>
                        </f:Panel>
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleForm1" OnClick="btnSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
    </form>
    <script src="../res/js/ApprovalButton.js"></script>
    <script>
        var windowClientID = '<%= Window1.ClientID %>';
        var gridClientID = '<%= Grid1.ClientID %>';
        var btnSaveClientID = '<%= btnSave.ClientID %>';
        var formClientID = '<%= SimpleForm1.ClientID %>';
        var hfFormIDClientID = '<%= hfFormID.ClientID %>';

        var tbxFormDEPT_NAMEClientID = '<%= tbxFormDEPT_NAME.ClientID %>';
        var ddlFormPARENT_IDClientID = '<%= ddlFormPARENT_ID.ClientID %>';
<%--        var tbxFormDEPT_CODEClientID = '<%= tbxFormDEPT_CODE.ClientID %>';--%>
        var tbxFormDING_CODEClientID = '<%= tbxFormDING_CODE.ClientID %>';
<%--        var tbxFormWARD_CODEClientID = '<%= tbxFormWARD_CODE.ClientID %>';
        var ddlFormDEPT_TYPEClientID = '<%= ddlFormDEPT_TYPE.ClientID %>';--%>
        var ddlFormDEPT_STATUSClientID = '<%= ddlFormDEPT_STATUS.ClientID %>';
        var tbxFormDEPT_REMARKClientID = '<%= tbxFormDEPT_REMARK.ClientID %>';
        function onNewButtonClick(event) {
            // 重置表单字段
            F(formClientID).reset();
            F(hfFormIDClientID).setValue(null);
            // 弹出窗体
            F(windowClientID).show();
            F(windowClientID).setTitle('新增数据');
        }
        function onEditButtonClick(event) {
            showEditWindow();
        }
        function showEditWindow(rowId) {
            var grid = F(gridClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }
            F(windowClientID).setTitle('编辑数据');
            // 当前行数据
            var rowValue = grid.getRowValue(rowId);
            // 使用当前行数据填充表单字段
            F(hfFormIDClientID).setValue(rowId);
            F(tbxFormDEPT_NAMEClientID).setValue(rowValue['DEPT_NAME']);
            F(ddlFormPARENT_IDClientID).setValue(rowValue['PARENT_ID']);
            //F(tbxFormDEPT_CODEClientID).setValue(rowValue['DEPT_CODE']);
            F(tbxFormDING_CODEClientID).setValue(rowValue['DING_CODE']);
            //F(tbxFormWARD_CODEClientID).setValue(rowValue['WARD_CODE']);
            //F(ddlFormDEPT_TYPEClientID).setValue(rowValue['DEPT_TYPE']);
            F(ddlFormDEPT_STATUSClientID).setValue(rowValue['DEPT_STATUS']);
            F(tbxFormDEPT_REMARKClientID).setValue(rowValue['DEPT_REMARK']);
            // 弹出新增窗体
            F(windowClientID).show();
        }
    </script>
</body>
</html>

